package com.zjf.carpark.utils;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

public class ResponseData implements Serializable {
    //返回信息
    private String message;
    //执行成功与否的表示
    private Integer code;

    private Integer count;

    //存放返回的数据
    private final Map<String, Object> data = new HashMap<String, Object>();

    public Map<String, Object> getData() {
        return data;
    }

    /**
     * 向data中添加数据
     *
     * @param key   数据名称，取个名字，用于前端获取
     * @param value 数据对象
     * @return 返回当前ResponseData对象
     */
    public void putDataValue(String key, Object value) {
        data.put(key, value);
    }

    public ResponseData() {
    }

    /**
     * 构造方法
     *
     * @param code    错误代码简述，例如：erro，success，loginError，validateError等
     * @param message 错误信息详述，例如：用户不存在、账号或密码错误等
     */
    public ResponseData(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public String getMessage() {
        return message;
    }

    public Integer getCode() {
        return code;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public Integer getCount() {
        return count;
    }

    public void setCount(Integer count) {
        this.count = count;
    }

    @Override
    public String toString() {
        return "ResponseData{" +
                "message='" + message + '\'' +
                ", code='" + code + '\'' +
                ", count=" + count +
                ", data=" + data +
                '}';
    }
}
